package com.kk.observer.observer;

/**
 * @author o_o
 * @date 2022-06-15
 */
public class Client {
    public static void main(String[] args) {

        CurrentWeather currentWeather = new CurrentWeather();
        YesterdayWeather yesterdayWeather = new YesterdayWeather();
        TomorrowWeather tomorrowWeather = new TomorrowWeather();

        //注册观察者后改变天气
        System.out.println("注册观察者后改变天气: ");
        WeatherData weatherData = new WeatherData();
        weatherData.registerObserve(currentWeather);
        weatherData.registerObserve(yesterdayWeather);
        weatherData.registerObserve(tomorrowWeather);
        weatherData.setWeatherData(30, 40, 50);

        //删除昨天后，展示天气，再改变天气
        System.out.println("\n删除昨天后，展示天气，再改变天气:");
        weatherData.removeObserver(yesterdayWeather);
        weatherData.notifyObserver();
        System.out.println("\n改变天气:");
        weatherData.setWeatherData(33, 44, 55);
    }
}
